package com.demo.config;

import com.demo.filter.MyFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MyFilterConfig {

    @Bean
    public FilterRegistrationBean<MyFilter> myFilter() {
        FilterRegistrationBean<MyFilter> filterRegistrationBean = new FilterRegistrationBean<>();
        //设置filter启动顺序
        filterRegistrationBean.setOrder(1);
        filterRegistrationBean.setFilter(new MyFilter());
        filterRegistrationBean.addInitParameter("email", "123456@qq.com");
        //设置拦截请求规则,这里拦截所有请求
        filterRegistrationBean.addUrlPatterns("/*");
        return filterRegistrationBean;
    }
}
